package evocarcassonne.tileseteditor.ui.javafx.components;

import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;

/**
 * Owner: Pierre Naubourg
 * Date: 07/10/13
 */
public class TileCell extends ListCell<String> {
    private Node getTileIcon() {
        return new ImageView(new Image("resources/icons/common-tile.png"));
    }

    @Override
    public void updateItem(String item, boolean empty) {
        super.updateItem(item, empty);

        if (item != null) {

            HBox boite = new HBox();
            boite.setSpacing(10);

            Node img = getTileIcon();
            Label label = new Label("Tile " + item);
            label.setMaxWidth(Double.MAX_VALUE);
            boite.getChildren().addAll(img, label);
            HBox.setHgrow(label, Priority.ALWAYS);


            setGraphic(boite);
        }
    }
}
